(function($) {
  $(document).ready(function() {
    $('#departure-picker').click(function() {
      $('#edit-departure').datepicker({
        changeMonth: true,
        changeYear: true,
        dateFormat: 'dd/mm/yy',
        altFormat: 'yy/mm/dd',
        onChangeMonthYear: function(y, m, i) {
          var d = i.selectedDay;
          jQuery(this).datepicker('setDate', new Date(y, m - 1, d));
        }
      }).focus();
    });
    
    $('#edit-departure').change(function() {
      $('#return-picker').removeClass('readonly');
      $('#return-picker').click(function() {
        $('#edit-return').datepicker({
          changeMonth: true,
          changeYear: true,
          dateFormat: 'dd/mm/yy',
          altFormat: 'yy/mm/dd',
          onChangeMonthYear: function(y, m, i) {
            var d = i.selectedDay;
            jQuery(this).datepicker('setDate', new Date(y, m - 1, d));
          }
        }).focus();
      });
    });
  });
} (jQuery));